/**
 * Copyright (C) 2010 DustedPixels.com
 */
package com.dustedpixels.cirt.model.machine.spectrum.ula;

import com.dustedpixels.cirt.model.core.Circuit;
import com.dustedpixels.cirt.model.core.In;
import com.dustedpixels.cirt.model.core.Out;
import com.dustedpixels.cirt.model.core.Script;

/**
 * Video beam control.
 * 
 * @author Michal Pociecha-Los (micapolos@gmail.com)
 */
@Circuit
public final class BeamControl {
  @In public int h;
  @In public int v;
  
  // Blank
  @Out public boolean blank;
  
  // true = horizontal sync active
  @Out public boolean hSync;
  
  // true = vertical sync active
  @Out public boolean vSync;
  
  @Script
  public void update() {
    hSync = (h > 256 + 48);
    vSync = (v > 192 + 56);
    blank = hSync || vSync || (h < -48);
  }
}
